home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / dflat8.zip / APPLICAT.C next >
Text File  |  1991-09-30  |  15KB  |  585 lines

  1. /* ------------- applicat.c ------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. static int ScreenHeight;
  6.  
  7. extern DBOX Display;
  8. extern DBOX Windows;
  9. extern DBOX Log;
  10.  
  11. static void ShellDOS(WINDOW);
  12. static void CreateMenu(WINDOW);
  13. static void CreateStatusBar(WINDOW);
  14. static void CloseAll(WINDOW);
  15. static void SelectColors(WINDOW);
  16. static void SetScreenHeight(int);
  17. static void MoreWindows(WINDOW);
  18. static void ChooseWindow(WINDOW, int);
  19. static void SelectTexture(void);
  20. static void SelectBorder(WINDOW);
  21. static void SelectTitle(WINDOW);
  22. static void SelectStatusBar(WINDOW);
  23. static void SelectLines(WINDOW);
  24. static int DisplayModified;
  25.  
  26. int ApplicationProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  27. {
  28.     int rtn, WasVisible;
  29.     static int AltDown = FALSE;
  30.  
  31.     switch (msg)    {
  32.         case CREATE_WINDOW:
  33.             ScreenHeight = SCREENHEIGHT;
  34.             if (!LoadConfig())
  35.                 cfg.ScreenLines = ScreenHeight;
  36.             if (!isVGA() && !DisplayModified)    {
  37.                 /* ---- modify Display Dialog Box for EGA, CGA ---- */
  38.                 CTLWINDOW *ct, *ct1;
  39.                 int i;
  40.                 ct = FindCommand(&Display, ID_OK, BUTTON);
  41.                 if (isEGA())
  42.                     ct1 = FindCommand(&Display, ID_50LINES, RADIOBUTTON);
  43.                 else    {
  44.                     CTLWINDOW *ct2;
  45.                     ct2 = FindCommand(&Display, ID_COLOR, RADIOBUTTON) - 1;
  46.                     ct2->dwnd.w++;
  47.                     for (i = 0; i < 7; i++)
  48.                         (ct2+i)->dwnd.x += 8;
  49.                     ct1 = FindCommand(&Display, ID_25LINES, RADIOBUTTON) - 1;
  50.                 }
  51.                 for (i = 0; i < 4; i++)
  52.                     *ct1++ = *ct++;
  53.                 DisplayModified = TRUE;
  54.             }
  55.             if (cfg.Border)
  56.                 SetCheckBox(&Display, ID_BORDER);
  57.             if (cfg.Title)
  58.                 SetCheckBox(&Display, ID_TITLE);
  59.             if (cfg.StatusBar)
  60.                 SetCheckBox(&Display, ID_STATUSBAR);
  61.             if (cfg.Texture)
  62.                 SetCheckBox(&Display, ID_TEXTURE);
  63.             if (cfg.mono == 1)
  64.                 PushRadioButton(&Display, ID_MONO);
  65.             else if (cfg.mono == 2)
  66.                 PushRadioButton(&Display, ID_REVERSE);
  67.             else
  68.                 PushRadioButton(&Display, ID_COLOR);
  69.             if (cfg.ScreenLines == 25)
  70.                 PushRadioButton(&Display, ID_25LINES);
  71.             else if (cfg.ScreenLines == 43)
  72.                 PushRadioButton(&Display, ID_43LINES);
  73.             else if (cfg.ScreenLines == 50)
  74.                 PushRadioButton(&Display, ID_50LINES);
  75.             if (SCREENHEIGHT != cfg.ScreenLines)    {
  76.                 SetScreenHeight(cfg.ScreenLines);
  77.                 if (WindowHeight(wnd) == ScreenHeight ||
  78.                         SCREENHEIGHT-1 < GetBottom(wnd))    {
  79.                     WindowHeight(wnd) = SCREENHEIGHT-1;
  80.                     GetBottom(wnd) = GetTop(wnd)+WindowHeight(wnd)-1;
  81.                     wnd->RestoredRC = WindowRect(wnd);
  82.                 }
  83.             }
  84.             SelectColors(wnd);
  85.             SelectBorder(wnd);
  86.             SelectTitle(wnd);
  87.             SelectStatusBar(wnd);
  88.             rtn = BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  89.             if (wnd->extension != NULL)
  90.                 CreateMenu(wnd);
  91.             CreateStatusBar(wnd);
  92.             LoadHelpFile();
  93.             SendMessage(NULL, SHOW_MOUSE, 0, 0);
  94.             return rtn;
  95.         case ADDSTATUS:
  96.             if (wnd->StatusBar != NULL)    {
  97.                 if (p1 && *(char *)p1)
  98.                     SendMessage(wnd->StatusBar, SETTEXT, p1, p2);
  99.                 else 
  100.                     SendMessage(wnd->StatusBar, CLEARTEXT, 0, 0);
  101.                 SendMessage(wnd->StatusBar, PAINT, 0, 0);
  102.             }
  103.             return TRUE;
  104.         case SETFOCUS:
  105.             if ((int)p1 == (inFocus != wnd))    {
  106.                 /* ---- setting/clearing focus ------ */
  107.                 if ((int)p1)
  108.                     SendMessage(inFocus, SETFOCUS, FALSE, 0);
  109.                 /* remove window from list */
  110.                 RemoveFocusWindow(wnd);
  111.                 /* move window to end/beginning of list */
  112.                 p1 ? AppendFocusWindow(wnd) : PrependFocusWindow(wnd);
  113.                 inFocus = p1 ? wnd : NULL;
  114.                 SendMessage(wnd, BORDER, 0, 0);
  115.                 return TRUE;
  116.             }
  117.             break;
  118.         case SIZE:
  119.             WasVisible = isVisible(wnd);
  120.             if (WasVisible)
  121.                 SendMessage(wnd, HIDE_WINDOW, 0, 0);
  122.             if (p1-GetLeft(wnd) < 30)
  123.                 p1 = GetLeft(wnd) + 30;
  124.             BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  125.             CreateMenu(wnd);
  126.             CreateStatusBar(wnd);
  127.             if (WasVisible)
  128.                 SendMessage(wnd, SHOW_WINDOW, 0, 0);
  129.             return TRUE;
  130.         case KEYBOARD:
  131.             AltDown = FALSE;
  132.             if (WindowMoving || WindowSizing)
  133.                     return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  134.             switch ((int) p1)    {
  135.                 case F1:
  136.                     return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  137.                 case ALT_F4:
  138.                     PostMessage(wnd, CLOSE_WINDOW, 0, 0);
  139.                     return TRUE;
  140.                 case ALT_F6:
  141.                     SetNextFocus(inFocus);
  142.                     SkipSystemWindows(FALSE);
  143.                     return TRUE;
  144.                 case ALT_HYPHEN:
  145.                     BuildSystemMenu(wnd);
  146.                     return TRUE;
  147.                 default:
  148.                     break;
  149.             }
  150.             PostMessage(wnd->MenuBarWnd, msg, p1, p2);
  151.             return TRUE;
  152.         case SHIFT_CHANGED:
  153.             if ((int)p1 & ALTKEY)
  154.                 AltDown = TRUE;
  155.             else if (AltDown)    {
  156.                 AltDown = FALSE;
  157.                 if (((int)p1 & ~ALTKEY) == 0)
  158.                     SendMessage(wnd->MenuBarWnd, KEYBOARD,
  159.                         wnd->MenuBarWnd == inFocus ? ESC : F10, 0);
  160.             }
  161.             return TRUE;
  162.         case PAINT:
  163.             if (isVisible(wnd))
  164.                 ClearWindow(wnd, (RECT *)p1, cfg.Texture ?
  165.                     APPLCHAR : ' ');
  166.             return TRUE;
  167.         case COMMAND:
  168.             switch ((int)p1)    {
  169.                 case ID_HELP:
  170.                     DisplayHelp(wnd, DFlatApplication);
  171.                     break;
  172.                 case ID_HELPHELP:
  173.                     DisplayHelp(wnd, "HelpHelp");
  174.                     break;
  175.                 case ID_EXTHELP:
  176.                     DisplayHelp(wnd, "ExtHelp");
  177.                     break;
  178.                 case ID_KEYSHELP:
  179.                     DisplayHelp(wnd, "KeysHelp");
  180.                     break;
  181.                 case ID_HELPINDEX:
  182.                     DisplayHelp(wnd, "HelpIndex");
  183.                     break;
  184.                 case ID_LOADHELP:
  185.                     LoadHelpFile();
  186.                     break;
  187.                 case ID_LOG:
  188.                     MessageLog(wnd);
  189.                     if (CheckBoxSetting(&Log, ID_LOGGING))
  190.                         SetCommandToggle(&MainMenu, ID_LOG);
  191.                     else
  192.                         ClearCommandToggle(&MainMenu, ID_LOG);
  193.                     break;
  194.                 case ID_DOS:
  195.                     ShellDOS(wnd);
  196.                     return TRUE;
  197.                 case ID_EXIT:
  198.                 case ID_SYSCLOSE:
  199.                     PostMessage(wnd, CLOSE_WINDOW, 0, 0);
  200.                     break;
  201.                 case ID_DISPLAY:
  202.                     if (DialogBox(wnd, &Display, TRUE, NULL))    {
  203.                         SendMessage(wnd, HIDE_WINDOW, 0, 0);
  204.                         SelectColors(wnd);
  205.                         SelectLines(wnd);
  206.                         SelectBorder(wnd);
  207.                         SelectTitle(wnd);
  208.                         SelectStatusBar(wnd);
  209.                         SelectTexture();
  210.                         CreateMenu(wnd);
  211.                         CreateStatusBar(wnd);
  212.                         SendMessage(wnd, SHOW_WINDOW, 0, 0);
  213.                     }
  214.                     break;
  215.                 case ID_SAVEOPTIONS:
  216.                     SaveConfig();
  217.                     break;
  218.                 case ID_WINDOW:
  219.                     ChooseWindow(wnd, (int)p2-2);
  220.                     break;
  221.                 case ID_CLOSEALL:
  222.                     CloseAll(wnd);
  223.                     break;
  224.                 case ID_MOREWINDOWS:
  225.                     MoreWindows(wnd);
  226.                     break;
  227.                 case ID_SYSRESTORE:
  228.                 case ID_SYSMOVE:
  229.                 case ID_SYSSIZE:
  230.                 case ID_SYSMINIMIZE:
  231.                 case ID_SYSMAXIMIZE:
  232.                     return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  233.                 default:
  234.                     if (inFocus != wnd->MenuBarWnd && inFocus != wnd)
  235.                         PostMessage(inFocus, msg, p1, p2);
  236.                     break;
  237.             }
  238.             return TRUE;
  239.         case CLOSE_WINDOW:    {
  240.             char exmsg[80];
  241.             sprintf(exmsg, "Exit %s?", DFlatApplication);
  242.             if (!YesNoBox(exmsg))
  243.                 return FALSE;
  244.             CloseAll(wnd);
  245.             PostMessage(NULL, STOP, 0, 0);
  246.             rtn = BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  247.             if (ScreenHeight != SCREENHEIGHT)
  248.                 SetScreenHeight(ScreenHeight);
  249.             UnLoadHelpFile();
  250.             SendMessage(NULL, HIDE_MOUSE, 0, 0);
  251.             return rtn;
  252.         }
  253.         default:
  254.             break;
  255.     }
  256.     return BaseWndProc(APPLICATION, wnd, msg, p1, p2);
  257. }
  258.  
  259. static void SwitchCursor(void)
  260. {
  261.     SendMessage(NULL, SAVE_CURSOR, 0, 0);
  262.     SwapCursorStack();
  263.     SendMessage(NULL, RESTORE_CURSOR, 0, 0);
  264. }
  265.  
  266. /* ------- Shell out to DOS ---------- */
  267. static void ShellDOS(WINDOW wnd)
  268. {
  269.     SendMessage(wnd, HIDE_WINDOW, 0, 0);
  270.     SwitchCursor();
  271.     if (ScreenHeight != SCREENHEIGHT)
  272.         SetScreenHeight(ScreenHeight);
  273.     SendMessage(NULL, HIDE_MOUSE, 0, 0);
  274.     printf("To return to %s, execute the DOS exit command.",
  275.                     DFlatApplication);
  276.     spawnl(P_WAIT, getenv("COMSPEC"), NULL);
  277.     if (SCREENHEIGHT != cfg.ScreenLines)
  278.         SetScreenHeight(cfg.ScreenLines);
  279.     SwitchCursor();
  280.     SendMessage(wnd, SHOW_WINDOW, 0, 0);
  281.     SendMessage(NULL, SHOW_MOUSE, 0, 0);
  282. }
  283.  
  284. static void CreateMenu(WINDOW wnd)
  285. {
  286.     AddAttribute(wnd, HASMENUBAR);
  287.     if (wnd->MenuBarWnd != NULL)
  288.         SendMessage(wnd->MenuBarWnd, CLOSE_WINDOW, 0, 0);
  289.     wnd->MenuBarWnd = CreateWindow(MENUBAR,
  290.                         NULL,
  291.                         GetClientLeft(wnd),
  292.                         GetClientTop(wnd)-1,
  293.                         1,
  294.                         ClientWidth(wnd),
  295.                         NULL,
  296.                         wnd,
  297.                         NULL,
  298.                         0);
  299.     SendMessage(wnd->MenuBarWnd, BUILDMENU, (PARAM) wnd->extension, 0);
  300.     AddAttribute(wnd->MenuBarWnd, VISIBLE);
  301. }
  302.  
  303. static void CreateStatusBar(WINDOW wnd)
  304. {
  305.     if (wnd->StatusBar != NULL)    {
  306.         SendMessage(wnd->StatusBar, CLOSE_WINDOW, 0, 0);
  307.         wnd->StatusBar = NULL;
  308.     }
  309.     if (TestAttribute(wnd, HASSTATUSBAR))    {
  310.         wnd->StatusBar = CreateWindow(STATUSBAR,
  311.                             NULL,
  312.                             GetClientLeft(wnd),
  313.                             GetBottom(wnd),
  314.                             1,
  315.                             ClientWidth(wnd),
  316.                             NULL,
  317.                             wnd,
  318.                             NULL,
  319.                             SAVESELF);
  320.         AddAttribute(wnd->StatusBar, VISIBLE);
  321.     }
  322. }
  323.  
  324. static char *Menus[9] = {
  325.     "~1.                      ",
  326.     "~2.                      ",
  327.     "~3.                      ",
  328.     "~4.                      ",
  329.     "~5.                      ",
  330.     "~6.                      ",
  331.     "~7.                      ",
  332.     "~8.                      ",
  333.     "~9.                      "
  334. };
  335.  
  336. static int WindowSel;
  337.  
  338. static char *WindowName(WINDOW wnd)
  339. {
  340.     if (GetTitle(wnd) == NULL)    {
  341.         if (GetClass(wnd) == DIALOG)
  342.             return ((DBOX *)(wnd->extension))->HelpName;
  343.         else 
  344.             return "Untitled";
  345.     }
  346.     else
  347.         return GetTitle(wnd);
  348. }
  349.  
  350. static WINDOW oldFocus;
  351.  
  352. void PrepWindowMenu(void *w, struct Menu *mnu)
  353. {
  354.     WINDOW wnd = w;
  355.     struct PopDown *p0 = mnu->Selections;
  356.     struct PopDown *pd = mnu->Selections + 2;
  357.     struct PopDown *ca = mnu->Selections + 13;
  358.     int MenuNo = 0;
  359.     WINDOW wnd1 = NULL;
  360.     mnu->Selection = 0;
  361.     oldFocus = NULL;
  362.     if (GetClass(wnd) != APPLICATION)    {
  363.         oldFocus = wnd;
  364.         wnd1 = Built.FirstWindow;
  365.         while (wnd1 != NULL && MenuNo < 9)    {
  366.             if (GetClass(wnd1) != MENUBAR &&
  367.                     GetClass(wnd1) != STATUSBAR &&
  368.                         GetParent(wnd1) == GetParent(wnd))    {
  369.                 strncpy(Menus[MenuNo]+4, WindowName(wnd1), 20);
  370.                 pd->SelectionTitle = Menus[MenuNo];
  371.                 if (wnd1 == oldFocus)    {
  372.                     pd->Attrib |= CHECKED;
  373.                     mnu->Selection = MenuNo+2;
  374.                 }
  375.                 else
  376.                     pd->Attrib &= ~CHECKED;
  377.                 pd++;
  378.                 MenuNo++;
  379.             }
  380.             wnd1 = NextWindowBuilt(wnd1);
  381.         }
  382.     }
  383.     if (MenuNo)
  384.         p0->SelectionTitle = "~Close all";
  385.     else
  386.         p0->SelectionTitle = NULL;
  387.     if (wnd1 != NULL)    {
  388.         *pd++ = *ca;
  389.         if (mnu->Selection == 0)
  390.             mnu->Selection = 11;
  391.     }
  392.     pd->SelectionTitle = NULL;
  393. }
  394.  
  395. static int WindowPrep(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  396. {
  397.     switch (msg)    {
  398.         case INITIATE_DIALOG:    {
  399.             WINDOW wnd1 = Built.FirstWindow;
  400.             WINDOW cwnd = ControlWindow(&Windows, ID_WINDOWLIST);
  401.             int sel = 0;
  402.             if (cwnd == NULL)
  403.                 return FALSE;
  404.             while (wnd1 != NULL)    {
  405.                 if (GetClass(wnd1) != MENUBAR &&
  406.                         GetClass(wnd1) != STATUSBAR &&
  407.                             GetParent(wnd1) == GetParent(wnd) &&
  408.                                 wnd1 != wnd)    {
  409.                     if (wnd1 == oldFocus)
  410.                         WindowSel = sel;
  411.                     SendMessage(cwnd, ADDTEXT, (PARAM) WindowName(wnd1), 0);
  412.                     sel++;
  413.                 }
  414.                 wnd1 = NextWindowBuilt(wnd1);
  415.             }
  416.             SendMessage(cwnd, LB_SETSELECTION, WindowSel, 0);
  417.             AddAttribute(cwnd, VSCROLLBAR);
  418.             PostMessage(cwnd, SHOW_WINDOW, 0, 0);
  419.             break;
  420.         }
  421.         case COMMAND:
  422.             switch ((int) p1)    {
  423.                 case ID_OK:
  424.                     if ((int)p2 == 0)
  425.                         WindowSel = SendMessage(ControlWindow(&Windows,
  426.                                     ID_WINDOWLIST),
  427.                                     LB_CURRENTSELECTION, 0, 0);
  428.                     break;
  429.                 case ID_WINDOWLIST:
  430.                     if ((int) p2 == LB_CHOOSE)
  431.                         SendMessage(wnd, COMMAND, ID_OK, 0);
  432.                     break;
  433.                 default:
  434.                     break;
  435.             }
  436.             break;
  437.         default:
  438.             break;
  439.     }
  440.     return DefaultWndProc(wnd, msg, p1, p2);
  441. }
  442.  
  443. static void MoreWindows(WINDOW wnd)
  444. {
  445.     if (DialogBox(wnd, &Windows, TRUE, WindowPrep))
  446.         ChooseWindow(wnd, WindowSel);
  447. }
  448.  
  449. static void ChooseWindow(WINDOW wnd, int WindowNo)
  450. {
  451.     WINDOW wnd1 = GetFirstChild(wnd);
  452.     while (wnd1 != NULL)    {
  453.         if (GetClass(wnd1) != MENUBAR && GetClass(wnd1) != STATUSBAR)
  454.             if (WindowNo-- == 0)
  455.                 break;
  456.         wnd1 = GetNextChild(wnd, wnd1);
  457.     }
  458.     if (wnd1 != NULL)    {
  459.         SendMessage(wnd1, SETFOCUS, TRUE, 0);
  460.         if (wnd1->condition == ISMINIMIZED)
  461.             SendMessage(wnd1, RESTORE, 0, 0);
  462.     }
  463. }
  464.  
  465. static void DoWindowColors(WINDOW wnd)
  466. {
  467.     WINDOW cwnd;
  468.     InitWindowColors(wnd);
  469.     cwnd = GetFirstChild(wnd);
  470.     while (cwnd != NULL)    {
  471.         DoWindowColors(cwnd);
  472.         cwnd = GetNextChild(wnd, cwnd);
  473.     }
  474. }
  475.  
  476. static void SelectColors(WINDOW wnd)
  477. {
  478.     if (RadioButtonSetting(&Display, ID_MONO))
  479.         cfg.mono = 1;
  480.     else if (RadioButtonSetting(&Display, ID_REVERSE))
  481.         cfg.mono = 2;
  482.     else
  483.         cfg.mono = 0;
  484.     if ((ismono() || video_mode == 2) && cfg.mono == 0)
  485.         cfg.mono = 1;
  486.  
  487.     if (cfg.mono == 1)
  488.         memcpy(cfg.clr, bw, sizeof bw);
  489.     else if (cfg.mono == 2)
  490.         memcpy(cfg.clr, reverse, sizeof reverse);
  491.     else
  492.         memcpy(cfg.clr, color, sizeof color);
  493.     DoWindowColors(wnd);
  494. }
  495.  
  496. static void SelectLines(WINDOW wnd)
  497. {
  498.     cfg.ScreenLines = 25;
  499.     if (isEGA() || isVGA())    {
  500.         if (RadioButtonSetting(&Display, ID_43LINES))
  501.             cfg.ScreenLines = 43;
  502.         else if (RadioButtonSetting(&Display, ID_50LINES))
  503.             cfg.ScreenLines = 50;
  504.     }
  505.     if (SCREENHEIGHT != cfg.ScreenLines)    {
  506.         int FullScreen = WindowHeight(wnd) == SCREENHEIGHT;
  507.         SetScreenHeight(cfg.ScreenLines);
  508.         if (FullScreen || SCREENHEIGHT-1 < GetBottom(wnd))
  509.             SendMessage(wnd, SIZE, (PARAM) GetRight(wnd),
  510.                 SCREENHEIGHT-1);
  511.     }
  512. }
  513.  
  514. static void SetScreenHeight(int height)
  515. {
  516.     if (isEGA() || isVGA())    {
  517.         SendMessage(NULL, SAVE_CURSOR, 0, 0);
  518.         switch (height)    {
  519.             case 25:
  520.                 Set25();
  521.                 break;
  522.             case 43:
  523.                 Set43();
  524.                 break;
  525.             case 50:
  526.                 Set50();
  527.                 break;
  528.             default:
  529.                 break;
  530.         }
  531.         SendMessage(NULL, RESTORE_CURSOR, 0, 0);
  532.         SendMessage(NULL, RESET_MOUSE, 0, 0);
  533.         SendMessage(NULL, SHOW_MOUSE, 0, 0);
  534.     }
  535. }
  536.  
  537. static void SelectTexture(void)
  538. {
  539.     cfg.Texture = CheckBoxSetting(&Display, ID_TEXTURE);
  540. }
  541.  
  542. static void SelectBorder(WINDOW wnd)
  543. {
  544.     cfg.Border = CheckBoxSetting(&Display, ID_BORDER);
  545.     if (cfg.Border)
  546.         AddAttribute(wnd, HASBORDER);
  547.     else
  548.         ClearAttribute(wnd, HASBORDER);
  549. }
  550.  
  551. static void SelectStatusBar(WINDOW wnd)
  552. {
  553.     cfg.StatusBar = CheckBoxSetting(&Display, ID_STATUSBAR);
  554.     if (cfg.StatusBar)
  555.         AddAttribute(wnd, HASSTATUSBAR);
  556.     else
  557.         ClearAttribute(wnd, HASSTATUSBAR);
  558. }
  559.  
  560. static void SelectTitle(WINDOW wnd)
  561. {
  562.     cfg.Title = CheckBoxSetting(&Display, ID_TITLE);
  563.     if (cfg.Title)
  564.         AddAttribute(wnd, HASTITLEBAR);
  565.     else
  566.         ClearAttribute(wnd, HASTITLEBAR);
  567. }
  568.  
  569. static void CloseAll(WINDOW wnd)
  570. {
  571.     WINDOW wnd1 = GetLastChild(wnd);
  572.     SendMessage(wnd, SETFOCUS, TRUE, 0);
  573.     while (wnd1 != NULL)    {
  574.         if (GetClass(wnd1) == MENUBAR || GetClass(wnd1) == STATUSBAR)
  575.             wnd1 = GetPrevChild(wnd, wnd1);
  576.         else    {
  577.             ClearVisible(wnd1);
  578.             SendMessage(wnd1, CLOSE_WINDOW, 0, 0);
  579.             wnd1 = GetLastChild(wnd);
  580.         }
  581.     }
  582.     SendMessage(wnd, PAINT, 0, 0);
  583. }
  584.  
  585.